package robocup.component.coach;

import robocup.component.geometry.Vektor;
import robocup.component.worldobjects.Player;

public class CoachProphet {

  private CoachWorld cwm;

  // private OLCoachTactic ol;

  /**
   * Constructor
   * 
   * @param ol
   */
  public CoachProphet(
      final OLCoachTactic ol) {

    // this.ol = ol;
    this.cwm = ol.getCwm();
  }

  /**
   * TODO: change to fastest opponent
   * 
   * @return the closest opponent to the ball
   */
  public Player getFastestOpponentToBall() {

    final Player[] players = this.cwm.getOpponents();
    Player closest = players[0];
    final Vektor ball = this.cwm.getBallPosition();

    for (int i = 1; i < 11; i++) {

      if (closest.getDistance(ball) < players[i].getDistance(ball)) {
        closest = players[i];
      }
    } // for

    return closest;
  }

  /**
   * TODO: change to fastest opponent
   * 
   * @return the closest opponent to the ball
   */
  public Player getFastestFriendToBall() {

    final Player[] players = this.cwm.getTeammates();
    Player closest = players[0];
    final Vektor ball = this.cwm.getBallPosition();

    for (int i = 1; i < 11; i++) {

      if (closest.getDistance(ball) < players[i].getDistance(ball)) {
        closest = players[i];
      }
    } // for

    return closest;
  }

}
